//initial photoshop
var originalRulerUnits = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS

//open folder
var jpegfolder = new Folder("/f/jpeg/jpeg_origin/");
var jpegfiles

if(jpegfolder.exists)
{
 jpegfiles = jpegfolder.getFiles("*.jpg");
}

//do with each jpeg file
for( iFile=0; iFile<jpegfiles.length; iFile++)
{
 var fileRef = File(jpegfiles[iFile])
 var docRef = app.open(fileRef)

 for( size=4; size>1; size--)
 {
  docRef.resizeImage( 128*size, 128*size );
  jpgFile = new File( "/f/jpeg/jpeg_all_size/" + fileRef.name + "-width" + size*128 + fileRef.name);
  
  jpgSaveOptions = new JPEGSaveOptions()
  jpgSaveOptions.embedColorProfile = true
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
  jpgSaveOptions.matte = MatteType.NONE
  jpgSaveOptions.quality = 1
  app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE)
  
  savedState = docRef.activeHistoryState
  
  for( angle=0; angle<180; angle++)
  {
   for( blurLength=1; blurLength<30; blurLength++)
   {
    docRef.artLayers[0].applyMotionBlur( angle, blurLength )
    
    jpgFile = new File( "/f/jpeg/jpeg_all_blur/" + 
         fileRef.name + "-width" + size*128 + 
         "-angle" + angle + "-blurLength"+blurLength + 
         fileRef.name);
    jpgSaveOptions = new JPEGSaveOptions()
    jpgSaveOptions.embedColorProfile = true
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
    jpgSaveOptions.matte = MatteType.NONE
    jpgSaveOptions.quality = 1
    app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE)
    
    docRef.activeHistoryState = savedState
   }
  }
 }
 app.activeDocument.close();
}

  
